import { IXMLAttr, IXMLAttrDict, IXMLAttrDicts } from "./IXMLAttr";
import { PropType } from "./PropType";
import { IXMLTagDict } from "./IXMLTag";
export class XMLConfig
{    
    public static getAttrDef(tagName:string, attrName:string):IXMLAttr
    {
        if(XMLConfig.attri[tagName])
            return XMLConfig.attri[tagName][attrName];
        return XMLConfig.attri.default[attrName];
    }
    /***属性定义
         * names字段表示属性的别名，注意属性可能是多个字段组合，它的值由分隔符隔开，所以别名是数组
         * type 字段类型
         * enum 字段的值可能是枚举，所以也记录一下枚举值
        */
     public static attri:IXMLAttrDicts = {
        transition_item_type:{
            "XY":{desc:"xy坐标",names:["x","y"],type:PropType.ARRAY_NUMBER},
            "Alpha":{desc:"透明度",names:["alpha"],type:PropType.ARRAY_NUMBER},
            "Size":{desc:"宽高",names:["width","height"],type:PropType.ARRAY_NUMBER},
            "Skew":{desc:"倾斜",names:["skewX","skewY"],type:PropType.ARRAY_NUMBER},
            "Rotation":{desc:"旋转",names:["rotation"],type:PropType.ARRAY_NUMBER},
            "Color":{desc:"颜色",names:["color"],type:PropType.STRING},
            "ColorFilter":{desc:"颜色滤镜",names:["brightness","contrast","saturation","hue"],type:PropType.ARRAY_NUMBER},
            "Pivot":{desc:"轴心",names:["anchorOffsetX","anchorOffsetY"],type:PropType.ARRAY_NUMBER},
            "Sound":{desc:"声音",names:["sound"],type:PropType.STRING},
            "Visible":{desc:"可见性",names:["visible"],type:PropType.BOOL},
            "Text":{desc:"文本",names:["text"],type:PropType.STRING}
        },
        transition:{
            "name":{desc:"动画对象-名称",type:PropType.STRING},
            "autoPlay":{desc:"动画对象-自动播放",type:PropType.BOOL},
            "autoPlayRepeat":{desc:"动画对象-自动重复",type:PropType.NUMBER},
            "autoPlayDelay":{desc:"动画对象-自动延迟",type:PropType.NUMBER},
            "frameRate":{desc:"动画对象-帧率",type:PropType.NUMBER},
        },
        item:{
            "time":{desc:"动画-时间",type:PropType.NUMBER},
            "type":{desc:"动画-类型",type:PropType.STRING,attrDef:"transition_item_type"},
            "target":{desc:"动画-目标",type:PropType.STRING},
            "tween":{desc:"动画-是否缓动",type:PropType.BOOL},
            "startValue":{desc:"动画-起始值",type:PropType.STRING},
            "endValue":{desc:"动画-结束值",type:PropType.STRING},
            "value":{desc:"动画-当前值",type:PropType.STRING},
            "duration":{desc:"动画-总时长",type:PropType.NUMBER},
        },
        default:{
            "name":{desc:"通用-组件实例名称",type:PropType.STRING},
            "xy":{desc:"通用-xy定位坐标",names:["x","y"],type:PropType.NUMBER},
            "size":{desc:"通用-宽高大小",names:["width","height"],type:PropType.NUMBER},
            "scale":{desc:"通用-缩放",names:["scaleX","scaleY"],type:PropType.NUMBER},
            "skew":{desc:"通用-倾斜",names:["skewX","skewY"],type:PropType.NUMBER},
            "rotation":{desc:"通用-旋转角度",type:PropType.NUMBER},
            "pivot":{desc:"通用-轴心坐标（相对自身）",names:["anchorX","anchorY"],type:PropType.NUMBER},
            "alpha":{desc:"通用-透明度",type:PropType.NUMBER},
            "visible":{desc:"通用-可见性",type:PropType.BOOL},
            "touchable":{desc:"通用-可触摸",names:["touchabled"],type:PropType.BOOL},
            "grayed":{desc:"通用-变灰",type:PropType.BOOL},
            "fold":{desc:"通用-翻转",enum:["both","hz","vt"],type:PropType.STRING},                        
            "fileName":{desc:"通用-资源文件名",type:PropType.STRING},
            "margin":{desc:"通用-边距(上,下,左,右)",names:["paddingTop","paddingBottom","paddingLeft","paddingRight"],type:PropType.NUMBER},

            "tooltips":{desc:"其他-提示文本",names:["toolTipString"],type:PropType.STRING},
            
            "defaultItem":{desc:"默认item组件引用",type:PropType.STRING},

            "type":{desc:"图形-类型",type:PropType.STRING,enum:["rect","eclipse","polygon","regular_polygon"]},
            "lineSize":{desc:"图形-线条粗细",type:PropType.NUMBER},
            "lineColor":{desc:"图形-线条颜色",type:PropType.STRING},
            "fillColor":{desc:"图形-填充颜色",type:PropType.STRING},
            "points":{desc:"图形-描点数组",type:PropType.ARRAY_NUMBER},
            "sides":{desc:"图形-边数",type:PropType.NUMBER},  
            "corner":{desc:"图形-圆角大小",type:PropType.NUMBER},
            
            "sidePair":{desc:"关联-布局",type:PropType.ARRAY, enum:["left-left", "right-right", "top-top", "bottom-bottom", "center-center", "middle-middle", "width-width", "height-height"]},      
            "target":{desc:"关联-目标",type:PropType.STRING},  
            
            "layout":{desc:"列表-布局方向",type:PropType.STRING, enum:["col", "row","flow_hz", "flow_vt", "pagination"], cls:["GYLite.GYListV", "GYLite.GYListH", "GYLite.GYGridV", "GYLite.GYGridH", "GYLite.GYGrid"]},
            "selectionMode":{desc:"列表-选择模式",type:PropType.STRING, enum:["single", "multiple", "multipleSingleClick", "none"]}, 
            "scrollBar":{desc:"列表-滚动条显示",names:["scrollPolicy"],type:PropType.STRING, enum:["auto", "visible", "hidden"]}, 
            "scrollBarMargin":{desc:"列表-滚动条定位",type:PropType.ARRAY_NUMBER},
            "autoItemSize":{desc:"列表-item尺寸自适应",type:PropType.BOOL},
            "lineGap":{desc:"列表-行距",type:PropType.NUMBER},
            "colGap":{desc:"列表-列距",type:PropType.NUMBER},
            "scrollBarRes":{desc:"列表-滚动条样式",names:["scrollerBarV", "scrollerBarH"],type:PropType.STRING},
            "scrollBarFlags":{desc:"列表-标志值([拖拽开关,16,32],[回弹开关,64,128])",type:PropType.ARRAY_NUMBER},

            "reverse":{desc:"进度条-是否反向",type:PropType.BOOL},
            "titleType":{desc:"进度条-标题类型",type:PropType.STRING, enum:["percent", "valueAndmax", "value", "max"]},
            "wholeNumbers":{desc:"滑块-是否整数输入",type:PropType.BOOL},
            "dropdown":{desc:"comboBox-下拉框组件引用",type:PropType.STRING},
                        
            "path":{desc:"package资源记录-组件的路径",type:PropType.STRING}, 
            "id":{desc:"package资源记录-组件的唯一id",type:PropType.STRING},  
            "scale9grid":{desc:"package资源记录-九宫格值[左,上,右,下],输出[x,y,w,h]",type:PropType.ARRAY},  
            "extention":{desc:"package资源记录-扩展组件引用",type:PropType.STRING},  
            "src":{desc:"package资源记录-资源src",type:PropType.STRING},
            "pkg":{desc:"package资源记录-资源pkg编码",type:PropType.STRING},
            "exported":{desc:"package资源记录-是否导出",type:PropType.BOOL},

            "text":{desc:"文本-文本内容",type:PropType.STRING},      
            "font":{desc:"文本-字体",type:PropType.STRING},
            "color":{desc:"文本-颜色",type:PropType.STRING},
            "fontSize":{desc:"文本-字体大小",names:["size"], type:PropType.NUMBER},
            "align":{desc:"文本-水平对齐",type:PropType.STRING},
            "singleLine":{desc:"文本-是否多行",names:["mutiline"],type:PropType.BOOL},
            "bold":{desc:"文本-加粗",type:PropType.BOOL},
            "italic":{desc:"文本-斜体",type:PropType.BOOL},
            "underline":{desc:"文本-下划线",type:PropType.BOOL},
            "leading":{desc:"文本-行距",type:PropType.NUMBER},
            "letterSpace":{desc:"文本-字距",type:PropType.NUMBER},
            "vAlign":{desc:"文本-垂直对齐",names:["verticalAlign"], type:PropType.STRING},
            "prompt":{desc:"文本-输入框默认文本",type:PropType.STRING},
            "maxLength":{desc:"文本-最大长度",names:["maxChars"], type:PropType.NUMBER},
            "restrict":{desc:"文本-正则限制",type:PropType.STRING},
            "password":{desc:"文本-文本内容",type:PropType.BOOL},
            "input":{desc:"文本-是否输入",type:PropType.BOOL},        
            "strokeColor":{desc:"文本-描边颜色",type:PropType.STRING},
            "strokeSize":{desc:"文本-描边粗细",names:["stroke"], type:PropType.NUMBER},
            "shadowColor":{desc:"文本-投影颜色",type:PropType.NUMBER},        
            "shadowOffset":{desc:"文本-投影偏移",names:["shadowOffsetX","shadowOffsetY"],type:PropType.NUMBER},

            "title":{desc:"文本标签-标题",type:PropType.STRING},      
            "titleColor":{desc:"文本标签-标题颜色",type:PropType.STRING},
            "titleFontSize":{desc:"文本标签-标题字体大小",type:PropType.NUMBER},
            
            "mode":{desc:"按钮-模式",type:PropType.STRING, enum:["button","Check","Radio"], cls:["GYLite.GYButton", "GYLite.GYCheckBox", "GYLite.GYRadioButton"]},            
        }
    };
    /**标签信息
     * cls 标签对应的类名，如果是显示对象，可用于创建显示对象
    */
    public static tag:IXMLTagDict = {
        "component":{cls:"GYLite.GYUIComponent", display:true},
        "image":{cls:"GYLite.GYScaleSprite", display:true},
        "text":{cls:"GYLite.GYText", display:true},
        "list":{cls:"GYLite.GYListV", display:true},
        "loader":{cls:"GYLite.GYLoadImage", display:true},
        "graph":{cls:"GYLite.GYSprite", display:true},
        "richText":{cls:"GYLite.GYRichText", display:true},
        "relation":{},
        "transition":{cls:"edc.ITransitionDict"},
        "item":{},        
        "displayList":{},
        "controller":{},
        "packageDescription":{},
        "resources":{},
        "Label":{cls:"GYLite.GYUIComponent"},
        "ComboBox":{cls:"GYLite.GYComboBox"},
        "Button":{cls:"GYLite.GYButton"},
        "ProgressBar":{cls:"GYLite.GYProgressBar"},
        "Slider":{cls:"GYLite.GYSlider"},
        "ScrollBar":{cls:"GYLite.GYScrollBase", clsEnum:["GYLite.GYScrollBarV", "GYLite.GYScrollBarH"]},
    };
}